﻿using System.Data;
using LibDBConnect;

namespace LibDataLayer
{
    public static class DalUsersInRoles
    {
        private static readonly SqlHelper Cls = new SqlHelper();
        #region[Get-Data]
        public static DataTable GetUsersInRoles(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("KEYWORDS", keywords);
            return Cls.GetData("sp_UsersInRoles_Get");
        }
        public static DataTable GetUsersInRolesFillter(string RoleName)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("RoleName", RoleName);
            return Cls.GetData("sp_UsersInRoles_Get_Fillter");
        }
        public static DataTable GetUsersInRolesEdit(string UserName)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("UserName", UserName);
            return Cls.GetData("sp_UsersInRoles_Get_Edit");
        }
        #endregion

        #region[Update]
        public static bool Update(DTOUsersInRoles obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("UserName", obj.UserName);
            Cls.AddParameter("btnAddNew", obj.btnAddNew);
            Cls.AddParameter("btnEdit", obj.btnEdit);
            Cls.AddParameter("btnSave", obj.btnSave);
            Cls.AddParameter("btnDel", obj.btnDel);
            Cls.AddParameter("btnLock", obj.btnLock);
            return Cls.ExecuteNonQuery("sp_UsersInRoles_Update");
        }
        public static bool UpdateRoles(DTOUsersInRoles obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("UserName", obj.UserName);
            Cls.AddParameter("RoleName", obj.RoleName);
            return Cls.ExecuteNonQuery("sp_UsersInRoles_Update_Group");
        }
        #endregion
    }

    public class DTOUsersInRoles
    {
        public string UserName { get; set; }
        public string RoleName { get; set; }
        public string ApplicationName { get; set; }
        public bool btnAddNew { get; set; }
        public bool btnEdit { get; set; }
        public bool btnSave { get; set; }
        public bool btnDel { get; set; }
        public bool btnLock { get; set; }
    }
}
